<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
	</head>

	<body>
		<div id="app">
			<test-item></test-item>
			<test-item></test-item>
			<test-item></test-item>
			<button @click="reset">重置</button>
		</div>
		<script src="https://unpkg.com/vue/dist/vue.js"></script>
		<script>
			var data = {
				counter: 1
			};
			Vue.component('test-item', {
				template: '<button @click="add">{{counter}}</button>',
				data: function() {
					return data 
				},
				methods:{
					add:function(){
						this.counter++;
					}
				}
			})
			var app = new Vue({
				el: '#app',
				data: function() {
					return data
				},
				methods: {
					reset: function() {
						this.counter = 0;
					}
				}
			})
			console.log(app)
		</script>
	</body>

</html>